package com.mbc.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mbc.mapper.PopularScienceMapper;
import com.mbc.service.PopularScienceService;
import com.mbc.vo.PopularScienceTweetInfoVO;
import com.mbc.vo.PopularScienceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;

/**
 * <p>
 * 科普表 服务实现类
 * </p>
 *
 * @author suimeng
 * @since 2024-04-16
 */
@Service
public class PopularScienceServiceImpl implements PopularScienceService {

    @Autowired
    private PopularScienceMapper popularScienceMapper;

    /**
     * 查询科普推文
     *
     * @return {@link ArrayList}<{@link PopularScienceVO}>
     */
    @Override
    public PageInfo<PopularScienceVO> getPopularScienceTweets(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        ArrayList<PopularScienceVO> list = popularScienceMapper.getPopularScienceTweets(LocalDateTime.now());
        return new PageInfo<>(list);
    }

    /**
     * 查询科普推文信息
     *
     * @param title 标题
     * @return {@link PopularScienceTweetInfoVO}
     */
    @Override
    public PopularScienceTweetInfoVO getPopularScienceTweetInfo(String title) {

        return popularScienceMapper.getPopularScienceTweetInfo(title);
    }
}
